{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "# SAKSHAT提供的数码管使用方法\n",
    "当前SAKSHAT为我们提供的方法参考：http://wiki.nxez.com/saks:sdk:libraries:digitaldisplaytm1637\n",
    "\n",
    "这里就直接摘录了，以下是创百科的内容:\n",
    "\n",
    "is_on(self)\n",
    "\n",
    "返回当前数码管的工作状态。true 或 false。\n",
    "\n",
    "numbers(self)\n",
    "\n",
    "返回当前显示的数字和字符的数组。每一位为数组的一个元素。\n",
    "\n",
    "ic(self)\n",
    "\n",
    "返回当前驱动数码管的IC对象。\n",
    "\n",
    "on(self)\n",
    "\n",
    "设置数码管为显示状态。\n",
    "\n",
    "off(self)\n",
    "\n",
    "设置数码管为停止显示状态。\n",
    "\n",
    "show(self, str)\n",
    "\n",
    "设置数码管显示的数字和字符并显示。str 为要显示的字符串。 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "#让数码管显示数字吧\n",
    "import time\n",
    "from sakshat import SAKSHAT\n",
    "from sakspins import SAKSPins as PINS\n",
    "\n",
    "if __name__ == \"__main__\":\n",
    "    try:\n",
    "        #Declare the SAKS Board\n",
    "        SAKS = SAKSHAT()\n",
    "        \n",
    "        #显示1.2.3.4\n",
    "        SAKS.digital_display.show(\"1.2.3.4\")\n",
    "        \n",
    "        time.sleep(3)\n",
    "        \n",
    "        #显示56.78\n",
    "        SAKS.digital_display.show(\"56.78\")\n",
    "        \n",
    "        time.sleep(3)\n",
    "        \n",
    "        #显示1\n",
    "        SAKS.digital_display.show(\"###1\")\n",
    "        \n",
    "        time.sleep(3)\n",
    "        \n",
    "        #别样的显示1\n",
    "        SAKS.digital_display.show(\"#1##\")\n",
    "        \n",
    "        time.sleep(3)\n",
    "        \n",
    "    except KeyboardInterrupt:\n",
    "        print(\"任务被终止了\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "当前数码管显示状态为:True\n",
      "当前数码管显示数字为:['2', '0', '1', '9']\n",
      "当前数码管显示状态为:False\n",
      "当前数码管显示数字为:['2', '0', '1', '9']\n",
      "当前数码管显示状态为:True\n",
      "当前数码管显示数字为:['2', '0', '1', '9']\n"
     ]
    }
   ],
   "source": [
    "#随意开启和关闭数码管显示\n",
    "import time\n",
    "from sakshat import SAKSHAT\n",
    "from sakspins import SAKSPins as PINS\n",
    "\n",
    "if __name__ == \"__main__\":\n",
    "    try:\n",
    "        #Declare the SAKS Board\n",
    "        SAKS = SAKSHAT()\n",
    "        \n",
    "        #显示2019\n",
    "        SAKS.digital_display.show(\"2019\")\n",
    "        dig_dis_status = SAKS.digital_display.is_on\n",
    "        dig_dis_num = SAKS.digital_display.numbers\n",
    "        print(\"当前数码管显示状态为:\" + str(dig_dis_status))\n",
    "        print(\"当前数码管显示数字为:\" + str(dig_dis_num))\n",
    "        \n",
    "        time.sleep(5)\n",
    "        \n",
    "        #关闭数码管显示\n",
    "        SAKS.digital_display.off()\n",
    "        dig_dis_status = SAKS.digital_display.is_on\n",
    "        dig_dis_num = SAKS.digital_display.numbers\n",
    "        print(\"当前数码管显示状态为:\" + str(dig_dis_status))\n",
    "        print(\"当前数码管显示数字为:\" + str(dig_dis_num))\n",
    "        \n",
    "        time.sleep(5)\n",
    "        \n",
    "        #再次点亮所有LED灯\n",
    "        SAKS.digital_display.on()\n",
    "        dig_dis_status = SAKS.digital_display.is_on\n",
    "        dig_dis_num = SAKS.digital_display.numbers\n",
    "        print(\"当前数码管显示状态为:\" + str(dig_dis_status))\n",
    "        print(\"当前数码管显示数字为:\" + str(dig_dis_num))\n",
    "        \n",
    "    except KeyboardInterrupt:\n",
    "        print(\"任务被终止了\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
